﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:mr="http://mishrareader.codeplex.com/Reader"
                    xmlns:mre="clr-namespace:MishraReader.Entities;assembly=MishraReader.Entities"
                    xmlns:mishraReader="clr-namespace:MishraReader;assembly=MishraReader.ViewModels">
    <DataTemplate DataType="{x:Type mre:Item}">
        <Grid x:Name="Grid" Margin="0,0,0,10" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="15" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <mr:BindableButton x:Name="readButton"
                Style="{StaticResource MetroCleanButton}" 
                                TextOptions.TextFormattingMode="Display"
                        Cursor="Hand"
                        ToolTip="{x:Static mishraReader:Strings.ToggleMarkAsRead}"
                        Content="{Binding}" 
                        Command="{DynamicResource toggleReadCommand}"
                        CommandParameter="{Binding}"
                        VerticalAlignment="Top" Margin="0,12,0,0">
                <Button.ContentTemplate>
                    <DataTemplate>
                        <Grid>
                            <Rectangle x:Name="rectReadStatus" Fill="{DynamicResource MetroLineLight}" Width="8" Height="8" />

                        </Grid>
                        <DataTemplate.Triggers>
                            <DataTrigger Binding="{Binding Unread}" Value="True">
                                <Setter TargetName="rectReadStatus" Property="Fill" Value="{DynamicResource MetroAccentBrush}"/>
                            </DataTrigger>
                        </DataTemplate.Triggers>
                    </DataTemplate>
                </Button.ContentTemplate>
            </mr:BindableButton>
            
            <!-- Read item in the feed list -->
            <StackPanel Grid.Column="1" Margin="5,0" >
                <TextBlock x:Name="tbTitle"  ToolTip="{Binding Title}" Text="{Binding Title}" TextTrimming="CharacterEllipsis"  
                               Foreground="{StaticResource MetroText}" 
                               Style="{StaticResource ItemTitle}" FontFamily="{DynamicResource DefaultFont}" FontSize="16" />

                <Grid TextOptions.TextFormattingMode="Display" x:Name="panSubTitle" Grid.Row="1" Margin="0,0,0,2" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBlock x:Name="tbFeed" DockPanel.Dock="Left" FontFamily="{DynamicResource DefaultFont}" Text="{Binding Subscription.Title}" Foreground="{DynamicResource MetroText}" FontSize="{DynamicResource SmallTextSize}" />
                    <!--<TextBlock Text=" - " Foreground="{DynamicResource MetroText}" FontSize="{DynamicResource SmallTextSize}" />-->
                    <TextBlock Grid.Column="1" DockPanel.Dock="Left" Text="{Binding FormatedPublicationDate}" Foreground="{DynamicResource MetroText}" FontSize="{DynamicResource SmallTextSize}" />
                </Grid>

                <TextBlock TextOptions.TextFormattingMode="Display" x:Name="tbDesc" Style="{StaticResource ItemDescription}" TextWrapping="Wrap" MaxHeight="33" TextTrimming="CharacterEllipsis" Text="{Binding Description}"  />
            </StackPanel>

        </Grid>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Unread}" Value="True">
                <Setter Property="Foreground" TargetName="tbFeed" Value="{DynamicResource MetroAccentBrush}" />
                <Setter Property="FontFamily" TargetName="tbTitle" Value="{DynamicResource SemiBoldFont}" />
                <Setter Property="Foreground" TargetName="tbTitle" Value="{DynamicResource MetroTextLight}" />
                <Setter Property="Foreground" TargetName="tbDesc" Value="{DynamicResource MetroText}" />

                <!--<Setter Property="Opacity" TargetName="Grid" Value="1" />-->

            </DataTrigger>
            <DataTrigger Binding="{Binding Description}" Value="">
                <Setter TargetName="tbDesc" Property="Visibility" Value="Collapsed" />
            </DataTrigger>
            <DataTrigger Binding="{Binding IsReadStateLocked}" Value="True">
                <Setter Property="Visibility" TargetName="readButton" Value="Hidden" />
            </DataTrigger>
            <DataTrigger Binding="{Binding Starred}" Value="True">
                <Setter Property="Visibility" TargetName="readButton" Value="Hidden" />
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
</ResourceDictionary>